<extend name="Layout/ins_page_nojs" />
<block name="content">
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        <link href="/sap/demo.css" rel="stylesheet" type="text/css" />
        <script src="/sap/scripts/boot.js" type="text/javascript"></script>

        <script type="text/javascript" src="/Public/Scripts/starrating/raty/jquery.js"></script>
        <script type="text/javascript" src="/Public/Scripts/starrating/raty/jquery.raty.js"></script>

        <style>
            .connent {list-style-type:none}
            .connent li{border-bottom: 1px solid gray}
        </style>

    </head>
    <body >

    <div>
        问题类型：<br>
        {$cnCategoryChain}
        <hr>
    </div>

    <div>
        请求人：<br>
        {$requestMan}
        <hr>
    </div>

    <div>
        问题主题：<br>
        {$qSubject}
        <hr>
    </div>


    <input value="{$wk.wk_no}" id='wkk_no' type="hidden">
    <div id='editForm1'>
        问题细节：{$remarks}
        <hr>
    </div>
    <br/>
    <div id='editForm1'>

        <if condition="($isaccess eq FALSE) ">
            <div id="score"></div>

            <script>
                $.fn.raty.defaults.path = '/Public/Scripts/starrating/raty/images';
                $(function() {
                    $('#score').raty({ readOnly: true, score: <?php echo $score ?> });
                });
            </script>

        </if>

        <?php if($isaccess){ ?>
        回复内容：
        <textarea  class="editor" id="remarks" name="remarks" class="col-xs-12"></textarea>
        <br/>
        <a class="mini-button" onclick="save" enabled="" id='saveBtn' style="">&nbsp;&nbsp;提交回复&nbsp;&nbsp;</a>

        <?php if($canOp){ ?>

        <?php if($canGoUp){ ?>
        <a class="mini-button" onclick="goup" enabled="" id='update-bt' style="">&nbsp;&nbsp;向上级转发&nbsp;&nbsp;</a>
        <?php }?>

        <?php if($canGoDown){ ?>
        <a class="mini-button" onclick="godown" enabled="" id='update-bt' style="">&nbsp;&nbsp;向下级转发&nbsp;&nbsp;</a>
        <?php }?>

        <?php }?>


        <?php if($issaveend){ ?>

        <div id="completeReview">
            <hr>
            <span id="targetKeep"></span>
            <input id="targetKeep-hint" class="input hint" type="hidden">
            <script>
            $.fn.raty.defaults.path = '/Public/Scripts/starrating/raty/images';

            $(function() {
                $('#targetKeep').raty({
                    cancel     : false,
                    target     : '#targetKeep-hint',
                    targetType : 'score',
                    targetKeep : true
                });
            });
            </script>
            <a class="mini-button" onclick="saveend" enabled="" id='saveendBtn' style="">&nbsp;&nbsp;完结&nbsp;&nbsp;</a>
        </div>

        <?php }?>
    </div>
    <?php }?>
    <br/>
    <!--<a href="javascript:jQuery('#show-connent').toggle()"> 查看回复记录</a>-->
    <div style="" id="show-connent">

        <?php foreach($wkinfo as $info){ ?>
        <ul class='connent' >
            <li>
                <?php echo $info['user']?> 在 <?php echo $info['ctime']?> 回复:<br/><br/>
                <?php echo $info['connent']?>

            <li>
        </ul>


        <?php };?>

    </div>

    </body>
    <script type="text/javascript">
        mini.parse();

        var saveBtn = mini.get("saveBtn");
        var saveendBtn = mini.get("saveendBtn");

        function goup(){
//            mini.mask({
//                el: document.body,
//                cls: 'mini-mask-loading',
//                html: '提交中...'
//            });
            var wk_no =jQuery("#wkk_no").val();
            $.ajax({
                url: "/wkorder/ordergoupdp20171120",
                data: { wk_no:wk_no},
                type: "post",
                dataType:'json',
                success: function (text) {
                    if(text.res>0){
                        mini.alert('操作成功');
                    }
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    alert(jqXHR.responseText);
                }
            });
        }

        function godown(){
//            mini.mask({
//                el: document.body,
//                cls: 'mini-mask-loading',
//                html: '提交中...'
//            });
            var wk_no =jQuery("#wkk_no").val();
            $.ajax({
                url: "/wkorder/ordergodowndp20171120",
                data: { wk_no:wk_no},
                type: "post",
                dataType:'json',
                success: function (text) {
                    if(text.res>0){
                        mini.alert('操作成功');
                    }
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    alert(jqXHR.responseText);
                }
            });
        }

        function saveend(){
//            mini.mask({
//                el: document.body,
//                cls: 'mini-mask-loading',
//                html: '提交中...'
//            });
            var wk_no =jQuery("#wkk_no").val();
            var starRating = $('#targetKeep-hint').val();
            if(starRating){
            }else{
                mini.alert("请评分！");
                return;
            }

            saveendBtn.setEnabled(false);

            $.ajax({
                url: "/wkorder/saveenddp20171120",
                data: { wk_no:wk_no, starRating:starRating},
                type: "post",
                dataType:'json',
                success: function (text) {
                    if(text.res>0){
                        mini.unmask(document.body);
                        mini.alert('操作成功');
                        saveendBtn.setEnabled(true);
                        window.history.back(-1);
                    }
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    alert(jqXHR.responseText);
                }
            });
        }

        function save() {


            var wk_no =jQuery("#wkk_no").val();
            if(wk_no==''){
                mini.alert('工单错误');
                return ;
            }
            var remarks = tinyMCE.activeEditor.getContent() ;
            if(remarks==''){
                mini.alert('请输入回复内容');
                return ;
            }

            if(remarks==''){
                mini.alert('请填写流转原因');
                return ;
            }

            mini.mask({
                el: document.body,
                cls: 'mini-mask-loading',
                html: '回复中...'
            });

            saveBtn.setEnabled(false);

            $.ajax({
                url: "/wkorder/saveaccessdp20171120",
                data: { wk_no:wk_no,remarks:remarks},
                type: "post",
                dataType:'json',
                success: function (text) {
                    if(text.res>0){
                        mini.unmask(document.body);
                        tinyMCE.activeEditor.setContent(' ') ;
                        mini.alert('回复成功!');
                        saveBtn.setEnabled(true);
                        window.history.back(-1);
                    }
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    alert(jqXHR.responseText);
                }
            });
        }

        window.onbeforeunload=function(e){
            var e=window.event||e;
            alert(11)
        }
    </script>
    </html>
</block>
